- reflection = reference.reflection_name
- partial_name = "#{reference.class.type}_fields"
- attrs = { class: "nested-#{reflection.to_s.parameterize}" }
- cardinality = reference.cardinality
- list = f.object.send(reflection).select{|v| v.reference_name.to_s == reference.name.to_s}
- unless cardinality == '*'
  - attrs[:data] ||= {}
  - if cardinality.minimum?
    - attrs[:data][:association_insertion_minimum] = cardinality.minimum
    - while f.object.send(reflection).select{|v| v.reference_name.to_s == reference.name.to_s}.size < cardinality.minimum
      - f.object.send(reflection).new(reference_name: reference.name)
  - if cardinality.maximum?
    - attrs[:data][:association_insertion_maximum] = cardinality.maximum
- list = f.object.send(reflection).select{|v| v.reference_name.to_s == reference.name.to_s}
.nested-association.nested-parameters{attrs}
  - prefix = namespace + reflection.to_s
  = f.simple_fields_for(reflection, list) do |d|
    = render "/backend/interventions/#{partial_name}", f: d, reference: reference, namespace: prefix
  .links
    = link_to_add_association :add_x.tl(x: reference.human_name), f, reflection, partial: "/backend/interventions/#{partial_name}", render_options: {locals: {thing: reflection, reference: reference, namespace: prefix}}, class: 'nested-add'
